#ifndef CONSENSUS_H_
#define CONSENSUS_H_

#include <omp.h>
#include <cassert>
#include <cstdlib>


template <class T>
class Consensus {
	public:
	
	Consensus(size_t N) {
		N_ = N;
		proposed_ = new T[N_];
	}
	
	~Consensus() {
		delete [] proposed_;
	}

	void Propose(T value) {
		size_t i = omp_get_thread_num();
		assert(i < N_);
		proposed_[i] = value;
	}

	virtual T Decide() = 0;
	
	protected:
	
	T *proposed_;
	size_t N_;
};

#endif // CONSENSUS_H_
